1 Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3 @page nvvid_backend_group 4 Ways to Video Decode with GIE Processing Sample
6 - [Overview](#overview)
7 - [Key Structure and Classes](#key)
8 - [Command Line Options](#options)
10 - - - - - - - - - - - - - - -
14 This use
case application showcases a typical appliance performing intelligent video analytics.
15 Application areas include
public safety, smart cities, and autonomous machines. This example demonstrates
16 four (4) concurrent video streams going through a decoding process
using the on chip decoders, video scaling
using on
17 chip scalar, and GPU compute. For simplicity of demonstration, only one of the channels will use GIE to perform
object identification
18 and generate bounding box around the identified
object. This sample also uses video converter functions
19 to
do various format convrsions and uses EGLImage to demonstrate buffer sharing and image display capability.
21 In
this sample,
object detection is limited to identifying cars in video streams of 960 x 540 resolution,
22 running up to 14 FPS. The network is based on GoogleNet. The inference is performed on a frame-by-frame basis
23 and no
object tracking is involved. Note that
this network is intended to be purely an example to showcase
24 GIE usage to build the compute pipeline quickly. The trained GoogleNet is provided as source and was trained
25 using NVIDIA DIGITS with roughly 3000 frames taken from 5-10 feet elevation. Varying levels of detection accuracy are expected based on the video samples fed in. Given that
this sample is locked to perform at half-HD resolutions under 10 FPS, video feeds with higher FPS
for inference will show stuttering during playback.
27 `
NvEGLImageFromFd` is NV-defined API to
return an EGLImage pointer from the file descriptor buffer that is allocated by way of Tegra mechanism. EGLImage buffer is then used by GIE to render the bounding box to the image.
29 This sample does not require a camera.
31 The image below shows a sample block diagram.
33 
35 The images below shows data flow details
for the channel
using GIE.
37 
39 `
NvEGLImageFromFd` is NVIDIA defined API to
return an `EGLImage` pointer form the file
40 descriptor buffer that is allocated by way of Tegra mechanism. `EGLImage` buffer is
41 then used by GIE to render the bounding box to the image.
43 #### Prerequisites ####
44 Before running the sample, you must have the following:
46 * CUDA 8.0 Toolkit
for L4T Rel 24.2
47 * GPU Inference Engine (GIE)
49 * README that provides details on the environment requirements to build and run the sample
51 - - - - - - - - - - - - - - -
53 ## Key Structure and Classes ##
55 There is a global structure `
struct context_t` that manages all the resources in the application.
59 |[
NvVideoDecoder](classNvVideoDecoder.html)|Contains all video decoding-related elements and functions.|
60 |[
NvVideoConverter](classNvVideoConverter.html)|Contains elements and functions for video format conversion.|
61 |
NvEglRenderer|Contains all EGL display rendering-related functions.|
62 |egl_image|The EGLImage used for CUDA processing.|
63 |conv_output_plane_buf_queue|Output plane queue for video conversion.|
64 |dec_capture_loop|The thread handler for decoding capture loop.|
68 The [
NvVideoDecoder](classNvVideoDecoder.html)
class creates a
new V4L2 Video Decoder.
69 The following table describes the key %
NvVideoDecoder members that
this sample uses.
73 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5) |Holds the V4L2 output plane.|
74 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|Holds the V4L2 capture plane.|
75 |createVideoDecoder |Static
function to create video decode
object.|
76 |subscribeEvent|Subscribes event.|
77 |setExtControls |Sets external control to V4L2 device.|
78 |setOutputPlaneFormat|Sets output plane format.|
79 |setCapturePlaneFormat|Sets capture plane format.|
81 |dqEvent|Dequeues the devent reported by the V4L2 device.|
82 |isInError|Checks
if under error state.|
86 The [
NvVideoConverter](classNvVideoConverter.html)
class packages all video converting related elements and functions.
87 It performs color space conversion, scaling and
88 conversion between hardware buffer memory and software buffer memory.
89 The following table describes the key %
NvVideoConverter members that
this sample uses.
93 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5) |Holds the output plane.|
94 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|Holds the capture plane.|
95 |[waitForIdle](classNvVideoConverter.html#a2f5d1a234427862adf9cae7323b5e24c) |Waits until all the buffers queued on the output plane are converted and dequeued from the capture plane. This is a blocking method.|
96 |[setCapturePlaneFormat](classNvVideoConverter.html#ad91e70f0e8b5f5a8b4deefa5a26ffe85)|Sets the format on the converter capture plane.|
97 |[setOutputPlaneFormat](classNvVideoConverter.html#a38b53f4d1e2c357360893756f417faf6) |Sets the format on the converter output plane.|
100 This
object is dervied from
class type [
NvV4l2ElementPlane](group__ee__nvv4lelementplane__group.html).
104 [
NvV4l2ElementPlane](group__ee__nvv4lelementplane__group.html) creates an [NVv4l2Element](classNvV4l2Element.html) plane.
105 The following table describes the key %
NvV4l2ElementPlane members used in this sample.
107 |Member |Description|
108 |-------------------|---|
109 |[setupPlane](classNvV4l2ElementPlane.html
#a89959f455e5222f686187cc826b1b345) |Sets up the plane of V4l2 element.|
110 |[deinitPlane](classNvV4l2ElementPlane.html#af89cfe87d8f818beb0478bcf5b72574c) |Destroys the plane of V4l2 element.|
111 |[setStreamStatus](classNvV4l2ElementPlane.html#a03164dde4d7ab41f3e92b41e13059316) |Starts/Stops the stream.|
112 |[setDQThreadCallback](classNvV4l2ElementPlane.html#a37f213325e0e4857180f5b2319317d6a)|Sets the callback
function of the `dqueue` buffer thread.|
113 |[startDQThread](classNvV4l2ElementPlane.html#a31f77f5e5ed1f320caa44a868a7cbedd) |Starts the thread of the `dqueue` buffer.|
114 |[stopDQThread](classNvV4l2ElementPlane.html#aa798d14493de321fa90aeab6d944ca87) |Stops the thread of the `dqueue` buffer.|
115 |[qBuffer](classNvV4l2ElementPlane.html#af4d52964fcfd37082f47682e457f5e95) |Queues a V4l2 buffer from the plane.|
116 |[dqBuffer](classNvV4l2ElementPlane.html#a8dfcbc666ee6f36a02abfb1170ae05cd) |Dequeues a V4l2 buffer from the plane.|
117 |[getNumBuffers](classNvV4l2ElementPlane.html#ac5cd394a7e0a4afd69395759aeac8787) |Gets the number of the V4l2 buffer.|
118 |getNumQueuedBuffers |Gets the number of the V4l2 buffer in the queue.|
119 |[getNthBuffer](classNvV4l2ElementPlane.html#a868d438908f3d267dd4af1033133892f) |Gets the \c %
NvBuffer queue
object at index N.|
123 GIE_Context provides a series of interfaces to load Caffe model and perform inference.
124 The following table describes the key %GIE_Context members used in
this sample.
126 |GIE_Context|Description|
127 |-----------|-----------|
128 |gie_alloc|Sets up all resources and parameters.|
129 |gie_free|Clears all resources.|
130 |caffeToGIEModel|Loads Caffe mode to GIE model.|
131 |doInference|Interface
for inference after GIE model is loaded.|
132 |parse_bbox|Parses Google net
's output results.|
133 |parse_hel_bbox|Parses Nvhel net's output results.|
134 |parse_net|Parses net info from proto file.|
136 2 global functions are used to create and destroy EGLImage from `dmabuf` file descriptor.
138 |Global Function|Description|
139 |---------------|-----------|
143 - - - - - - - - - - - - - - -
145 ## Command Line Options ##
147 To run the sample, execute:
149 backend <channel-num> <in-file1> <in-file2>... <in-format> [options]
151 The following video formats are supported
for use with command line options:
158 The table below describes the available options.
160 |Command|Description|
161 |---------------|-----------|
162 |-h, --help|Prints the help text.|
163 |-fps <fps>|Displays rate in frames per second. Default = 30.|
164 |--s| Provides a statistic of each channel.|
165 |-run-opt <0-3>| 0=
default, 1=parser only, 2=parser + decoder, 3=parser + decoder + VIC|
166 |--input-nalu|Specifies that the
default input to the decoder is in nalu units.|
167 |--input-chunks|Specifies that the
default input to the decoder is in chunk of bytes.|
168 |--gie-deployfile|Sets the deploy file name.|
169 |--gie-modelfile|Sets the model file name.|
170 |--gie-proc-interval|Sets the process interval; 1 frame is processed every gie-proc-interval.|
171 |--gie-float16|0=
default, 1=float16, 2=float32.|
173 For X11 technical details, see:
Defines a helper class for V4L2 Video Decoder.
Defines a helper class for operations performed on a V4L2 Element plane.
Class representing a buffer.
EGLImageKHR NvEGLImageFromFd(EGLDisplay display, int dmabuf_fd)
This method must be used for getting EGLImage from dmabuf-fd.
Defines a helper class for V4L2 Video Converter.
NvEglRenderer is a helper class for rendering using EGL and OpenGL ES 2.0.
int NvDestroyEGLImage(EGLDisplay display, EGLImageKHR eglImage)
This method must be used for destroying EGLImage object.